{% extends "index.html" %}
{% load ifpermit %}

{% block mainmenu %}
<div class="button" onclick="javascript:document.location='/'">News</div>
<div class="button" onclick="javascript:document.location='/folders'">Folders</div>
<div class="button" onclick="javascript:document.location='/groups'">Groups</div>
<div class="button" onclick="javascript:document.location='/search'">Search</div>
<div class="button" onclick="javascript:document.location='/profile'">Profile</div>
<div class="button" onclick="javascript:document.location='/logout'">Logout</div>
{% endblock %}

{% block rightpart %}
<div class="folderheader">Groups</div>
{% if groups %}
<div class="rightmenu" onclick="javascript:document.location='/groups/';">All</div>
{% for p in groups %}
<div id="opengroup{{p.id}}" class="rightmenu" onclick="javascript:document.location='/group/{{p.id}}';">{{p.title}}</div>
{% endfor %}
{% endif %}
<div id="creategroup" class="rightmenu" onclick="javascript:create_new_group();">Create new group</div>
{% endblock %}


{% block leftpart %}
<div class="groupbody" id="groupbody{{group.id}}">

<div class="folderheader" id="groupheader{{group.id}}">
<div class="folderheadertext">{{group.title}}
{% ifnotequal rights "N" %}
you're {{ rights|full_right }} of this group
{% endifnotequal %}
</div>

<div class="smallbutton" onclick="javascript:document.location='/group/{{group.id}}/folders';">folders</div>
<div class="smallbutton" onclick="javascript:document.location='/group/{{group.id}}/users';">users</div>
<div class="smallbutton" onclick="javascript:document.location='/group/{{group.id}}/topics';">topics</div>

{% ifequal rights "N" %}
<div class="smallbutton" onclick="javascript:subscribe_group({{group.id}});">subscribe</div>
{% endifequal %}
{% ifequal rights "R" %}
<div class="smallbutton" onclick="javascript:unsubscribe_group({{group.id}});">unsubscribe</div>
{% endifequal %}

{% ifpermit rights C %}
<div class="smallbutton" onclick="javascript:purgegroup({{group.id}});">purge</div>
{% endifpermit %}
</div>

<div class="groupfolders" id="groupfolders{{group.id}}">
<h1><a href="/profile/{{user.id}}">{{user}}</a> ({{user.first_name}} {{user.last_name}}) - {{ hisrights|full_right}} of this group</h1>
{% ifpermit rights M %}

{% ifnotequal hisrights "C" %}
{% ifpermit hisrights A %}
<a href="about:none" onclick="javascript:$('.leftpart').load('/group/{{group.id}}/user/{{user.id}}/R');">Remove administrator rights</a><br />
{% else %}
{% ifpermit hisrights M %}
<a href="about:none" onclick="javascript:$('.leftpart').load('/group/{{group.id}}/user/{{user.id}}/R');">Remove moderator rights</a><br />
{% else %}
<a href="about:none" onclick="javascript:$('.leftpart').load('/group/{{group.id}}/user/{{user.id}}/M');">Grant moderator rights</a><br />
{% endifpermit %}
<a href="about:none" onclick="javascript:$('.leftpart').load('/group/{{group.id}}/user/{{user.id}}/A');">Grant administrator rights</a><br />
{% endifpermit %}
{% endifnotequal %}

{% endifpermit %}
<h2>His/her activity:</h2> 
<b>Folders</b>: {{folders}}<br />
<b>Topics</b>: {{topics}}<br />
<b>Comments</b>: {{comments}}<br />
</div>
</div>
{% endblock %}




